<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用例集编辑</title>
    <link href="https://unpkg.com/gridjs/dist/theme/mermaid.min.css" rel="stylesheet" />
    <style>
        /* 强制浅色主题 */
        body {
            background: #f8f9fa !important;
            color: #333 !important;
        }
        .edit-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            max-width: 1000px;
            margin: 32px auto 24px auto;
            padding: 0 16px;
        }
        .edit-header .export-group {
            display: flex;
            gap: 12px;
            align-items: center;
        }
        .edit-header select, .edit-header button {
            font-size: 15px;
            padding: 6px 16px;
            border-radius: 8px;
            border: 1px solid #e0e0e0;
            background: #fff;
            color: #333;
            cursor: pointer;
        }
        .edit-header button {
            background: #00bfae;
            color: #fff;
            border: none;
            font-weight: 500;
            transition: background 0.2s;
        }
        .edit-header button:hover {
            background: #64ffda;
            color: #23243a;
        }
        .edit-title {
            font-size: 22px;
            font-weight: 600;
            color: #23243a;
            display: flex;
            align-items: center;
            gap: 16px;
        }
        .back-btn {
            background: #f0f0f0;
            border: none;
            padding: 8px 16px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 14px;
            color: #333;
            transition: background 0.2s;
        }
        .back-btn:hover {
            background: #e0e0e0;
        }
        .edit-table-wrap {
            max-width: 1000px;
            margin: 0 auto 40px auto;
            background: #fff;
            border-radius: 18px;
            box-shadow: 0 2px 12px rgba(0,0,0,0.04);
            padding: 24px 12px 32px 12px;
        }
        @media (max-width: 1100px) {
            .edit-header, .edit-table-wrap { max-width: 100%; }
        }
        /* 表格样式 */
        .table-container {
            max-height: 600px;
            overflow-y: auto;
            border-radius: 8px;
            border: 1px solid #e0e0e0;
        }
        .editable-table {
            width: 100%;
            border-collapse: collapse;
            background: #fff;
        }
        .editable-table th {
            background: #f8f9fa;
            padding: 12px 8px;
            text-align: center;
            font-weight: 600;
            color: #333;
            border-bottom: 2px solid #e0e0e0;
            position: sticky;
            top: 0;
            z-index: 10;
        }
        .editable-table td {
            padding: 8px;
            text-align: left;
            border-bottom: 1px solid #f0f0f0;
            position: relative;
            vertical-align: top;
            min-width: 120px;
        }
        .editable-table td:hover {
            background: #f8f9fa;
        }
        .editable-table textarea {
            width: 100%;
            min-height: 60px;
            border: none;
            background: transparent;
            font-size: 14px;
            color: #333;
            outline: none;
            resize: vertical;
            font-family: inherit;
            line-height: 1.4;
            padding: 4px;
            box-sizing: border-box;
        }
        .editable-table textarea:focus {
            background: #fff;
            border: 1px solid #00bfae;
            border-radius: 4px;
        }
        .editable-table th {
            background: #f8f9fa;
            padding: 12px 8px;
            text-align: center;
            font-weight: 600;
            color: #333;
            border-bottom: 2px solid #e0e0e0;
            position: sticky;
            top: 0;
            z-index: 10;
            min-width: 120px;
        }
        .delete-btn {
            background: #ff4757;
            color: #fff;
            border: none;
            padding: 8px 12px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
        .delete-btn:hover {
            background: #ff3742;
        }
        .editable-table .delete-btn {
            font-size: 14px;
            padding: 5px 12px;
        }
        .table-header {
            margin-bottom: 16px;
        }
        .add-btn {
            background: #00bfae;
            color: #fff;
            border: none;
            padding: 8px 16px;
            border-radius: 8px;
            font-size: 14px;
            cursor: pointer;
            transition: background 0.2s;
        }
        .add-btn:hover:not(:disabled) {
            background: #64ffda;
            color: #23243a;
        }
        .add-btn:disabled {
            background: #6c757d;
            color: #fff;
            cursor: not-allowed;
        }
        .add-btn:disabled:hover {
            background: #6c757d;
            color: #fff;
        }
        .editable-table td, .editable-table th {
            text-align: center;
        }
    </style>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="edit-header">
        <div class="edit-title">
            <button id="backBtn" class="back-btn"><i class="fas fa-arrow-left"></i> 返回</button>
            用例集编辑
        </div>
        <div class="export-group">
            <select id="exportType">
                <option value="csv">CSV</option>
                <option value="markdown">Markdown</option>
                <option value="excel">Excel</option>
                <option value="word">Word</option>
            </select>
            <button id="downloadBtn"><i class="fas fa-download"></i> 下载</button>
        </div>
    </div>
    <div class="edit-table-wrap">
        <div class="table-header">
            <div style="display: flex; gap: 12px; align-items: center;">
                <button id="addBtn" class="add-btn"><i class="fas fa-plus"></i> 新增行</button>
                <!-- 保存按钮已移除 -->
            </div>
        </div>
        <div class="table-container">
            <table id="caseTable" class="editable-table">
                <thead>
                    <tr>
                        <th>功能模块</th>
                        <th>用例编号</th>
                        <th>测试场景</th>
                        <th>前置条件</th>
                        <th>测试步骤</th>
                        <th>预期结果</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody id="tableBody">
                    <!-- 数据行将在这里动态生成 -->
                </tbody>
            </table>
        </div>
    </div>
    <div id="addCaseModal" class="modal" style="display:none;">
      <div class="modal-content">
        <span class="close" id="closeAddCaseModal">&times;</span>
        <h3>新增测试用例</h3>
        <form id="addCaseForm">
          <label>功能模块：<input name="module" required></label><br>
          <label>用例编号：<input name="casenum" required></label><br>
          <label>测试场景：<input name="scene" required></label><br>
          <label>前置条件：<input name="pre" required></label><br>
          <label>测试步骤：<input name="steps" required></label><br>
          <label>预期结果：<input name="expect" required></label><br>
          <button type="submit">提交</button>
        </form>
      </div>
    </div>
    <style>
    .modal { position:fixed; left:0; top:0; width:100vw; height:100vh; background:rgba(0,0,0,0.3); display:flex; align-items:center; justify-content:center; z-index:9999;}
    .modal-content { background:#fff; padding:32px 32px 24px 32px; border-radius:18px; min-width:340px; position:relative; box-shadow:0 4px 24px rgba(0,0,0,0.08); display:flex; flex-direction:column; align-items:center;}
    .close { position:absolute; right:18px; top:12px; cursor:pointer; font-size:22px; color:#888; transition:color 0.2s;}
    .close:hover { color:#00bfae; }
    #addCaseForm {
      display: flex;
      flex-wrap: wrap;
      flex-direction: row;
      gap: 18px 16px;
      width: 100%;
      max-width: 700px;
      margin-top: 10px;
      align-items: flex-end;
      justify-content: center;
    }
    #addCaseForm label {
      display: flex;
      flex-direction: column;
      font-size: 15px;
      color: #23243a;
      font-weight: 500;
      gap: 6px;
      min-width: 140px;
      flex: 1 1 180px;
    }
    #addCaseForm input {
      border: 1px solid #e0e0e0;
      border-radius: 8px;
      padding: 10px 12px;
      font-size: 15px;
      background: #f8f9fa;
      color: #333;
      outline: none;
      transition: border 0.2s, box-shadow 0.2s;
      box-shadow: 0 1px 4px rgba(0,0,0,0.03);
    }
    #addCaseForm input:focus {
      border: 1.5px solid #00bfae;
      background: #fff;
      box-shadow: 0 2px 8px rgba(0,191,174,0.08);
    }
    #addCaseForm button[type="submit"] {
      background: #00bfae;
      color: #fff;
      border: none;
      border-radius: 8px;
      padding: 10px 32px;
      font-size: 16px;
      font-weight: 600;
      cursor: pointer;
      box-shadow: 0 2px 8px rgba(0,191,174,0.08);
      transition: background 0.2s, color 0.2s;
      margin-left: 12px;
      margin-top: 0;
      height: 44px;
      align-self: stretch;
      flex: 0 0 120px;
    }
    #addCaseForm button[type="submit"]:hover {
      background: #64ffda;
      color: #23243a;
    }
    .modal-content h3 {
      font-size: 20px;
      font-weight: 600;
      color: #00bfae;
      margin-bottom: 18px;
      letter-spacing: 1px;
      text-align: center;
    }
    @media (max-width: 900px) {
      #addCaseForm { max-width: 100%; }
    }
    @media (max-width: 700px) {
      #addCaseForm label { min-width: 100px; flex-basis: 120px; }
      #addCaseForm { gap: 12px 8px; }
    }
    @media (max-width: 500px) {
      .modal-content { padding: 16px 4vw 12px 4vw; min-width: 0; }
      #addCaseForm { flex-direction: column; flex-wrap: nowrap; gap: 12px; }
      #addCaseForm label { min-width: 0; flex-basis: auto; }
      #addCaseForm button[type="submit"] { width: 100%; margin-left: 0; }
    }
    </style>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.8.2/jspdf.plugin.autotable.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
    <script src="edit.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" />
</body>
</html> 